#include <cstdint>
#include <functional>
#include <chrono>

void GtestLogSleep(uint64_t ms);

template <typename CallBack> int32_t WaitCondTrue(const CallBack& callback, uint64_t msTimeout = 0)
{
    auto st = std::chrono::steady_clock::now();
    auto timeout = std::chrono::milliseconds(msTimeout);
    while (!callback())
    {
        auto cur = std::chrono::steady_clock::now();
        auto dur = std::chrono::duration_cast<std::chrono::milliseconds>(cur - st);

        if (msTimeout != 0 && dur > timeout)
            return -1;
    }
    return 0;
}